package com.jsc.common.config.swaggerconf;


import com.jsc.common.ymlparams.SystemParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.*;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @ClassName SwaggerConfig
 * @Date 2021/6/26 0026 下午 14:39
 * @Author Administrator
 * @Description TODO
 * Version 1.0
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    //http://localhost:9000/xiamebank/swagger-ui.html

    @Autowired
    private SystemParams systemParams;

    @org.springframework.context.annotation.Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.jsc.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title(systemParams.projectName + "测试项目接口文档")
                .description("")
                .termsOfServiceUrl("http://" + systemParams.myIp)
                .contact("dunjiaxing")
                .version("1.0")
                .build();
    }

}
